<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="../../vue.js"></script>
    <title>Document</title>
    <style>
      .box {
        width: 200px;
        height: 200px;
      }
      .bor {
        border: 2px dotted green;
      }
      .pink {
        background-color: pink;
      }
      .yellow {
        background-color: yellow;
      }
    </style>
  </head>
  <body>
    <!-- 通过class名来改变标签的样式，比动态绑定style更常用 -->
    <div id="app">
      <!-- 写法一：字符串 -->
      <div class="box" :class="ispink?'pink':'yellow'"></div>
      <!-- 写法二：对象 -->
      <div class="box" :class="{bor:true,yellow:true,pink:false}"></div>
      <div class="box" :class="boxclass"></div>
      <!-- 写法三：数组 -->
      <div class="box" :class="['bor','pink']"></div>
    </div>
    <script>
      const vm = new Vue({
        el: '#app',
        data() {
          return {
            ispink: true,
            boxclass: { bor: true, yellow: true, pink: false },
          };
        },
      });
    </script>
  </body>
</html>
